#include <cmdReadBaseInform.h>
#include <deviceOperateSN.h>

void masterCmdCvrtFuncName(ReadBaseInfo)(struct masterCmdStructName(ReadBaseInfo) *masterData)
{
    masterData = NULL;
}
void devCmdCvrtFuncName(ReadBaseInfo)(struct devCmdStructName(ReadBaseInfo) *devData)
{
    convertOvtBigSysI16Pro(devData->deviceMaxPackSize);
}

int devCmdDealFuncName(ReadBaseInfo)(struct ptcCmdOptStruct *cmdOpt)
{
    struct masterCmdStructName(ReadBaseInfo) *masterData = ptcCmdGetUsrPtr(cmdOpt);
    struct devCmdStructName(ReadBaseInfo) *devData = ptcCmdGetUsrPtr(cmdOpt);
    int tmpResult = cmdExeRslt_OK;
    if(ptcCmdGetUserSize(cmdOpt) < sizeof(struct masterCmdStructName(ReadBaseInfo)))
    {
        logerror("%d", ptcCmdGetUserSize(cmdOpt));
        tmpResult = cmdExeRslt_MasterSizeErr;
        goto cmdDealErrorResp;
    }
    // do user logic
    logHexData("ReadBaseInfo:", masterData->remain, sizeof(masterData->remain));
    // pack response user data
    if(ptcCmdSetUsrSize(cmdOpt, sizeof(struct devCmdStructName(ReadBaseInfo))) < 0)
    {
        logerror("%d", sizeof(struct devCmdStructName(ReadBaseInfo)));
        tmpResult = cmdExeRslt_DevSizeErr;
        goto cmdDealErrorResp;
    }
    memcpypro(devData->version, sizeof(devData->version), DEVICE_VERSION_STR_DATA, sizeof(DEVICE_VERSION_STR_DATA));
    memcpypro(devData->serialnumber, sizeof(devData->serialnumber), deviceSnString, sizeof(deviceSnString));
    devData->deviceType = DEVICE_TYPE_OF_THIS;
    devData->deviceMaxPackSize = cmdOpt->parser.pksize;
cmdDealErrorResp:
    // pack response cmd head
    if(tmpResult != cmdExeRslt_OK)
    {
        ptcCmdSetUsrSize(cmdOpt, 0);
    }
    ptcCmdSetCmdResp(cmdOpt, tmpResult);
    ptcPackSetCrypte(&cmdOpt->parser, protocolParseCrypte_None);// set crypte type if you want
    // pack pack head by 485 cmd function. there not config
    return 0;
}

